﻿CREATE VIEW dbo.Boat_Tbl_View
AS
SELECT     BoatGenID, SOURCE, Designer, BoatMnfID, Manufacturer, BoatRange, BoatModel, BoatType, BoatTypeID, Draft, BoatLoaGrpID, Loa, FirstHullNo, LastHullNo, 
                      DesignYear, BoatName, [SAIL NUMBER], BoatRigGrpID, Smart, Expr1, Cb, CERTIFICATE, CountryID, Beam, Displ, Dl, Dwsd, [Mast No], MastID, BoomID, BAS, FL, I, J, 
                      P, E, Py, Ey, Ios, Jos, Isp, Iss, Jss, Iys, Jys, Igs, Jgs, POLE_SPRIT, Spl, Stl, FURLER, [Fwd_Aft Lower], [Half width at D1 anchorage], [Half width at V1 anchorage], 
                      HasImage, Headstay1ID, Headstay1ID2, Headstay1ID3, HHB, HHW, HSA, HTW, LP, LL, LLM, LLY, LPY, MHW, MTW, MUW, ASF, ASHW, ASLE, ASLU, SL, SF, SHW, 
                      SMW, SPA, [Import ID], [Keel Stepped  _Yes_N0], LastUpdated, [SP1 Ht], [Length SP1], [Lift SP1], SP2, [Length SP2], [Lift SP2], [SP3 Ht], [Length SP3], [Lift SP3], Expr2, 
                      Chainplates_partner, CHECKSTAYS, [Inter stay], SPREADERS, JUMPERS, RUNNERS, [Lower runner], [Main Area], Mast_deck_Waterline, BowRake, BowShear, 
                      [Angle Chainplates], [Cable type], [Ø Backstay], [Ø D1], [Ø D1 Avt], [Ø D2], [Ø D3], [Ø Double backstay], [Ø Head stay], [Ø intermediate], [Ø Lower shroud], 
                      [Ø Lower stay], [Ø Top shroud], [Ø V1], [Ø V2], [Ø V2D3], [Ø V3D4], [Ø Y  backstay], [Pied arrière _au pont_ du pataras ou bastaque principale], Private, Prop, Rating, 
                      Rigging, RigType, [Gz max _m_], [Rm max _kg#m_ Designer], [Rm max  _kg#m_], [RM Test configuration], SailPlan, TranShear, Upsd, Measured, MeasurementForm, 
                      Notes, Concatstring, REPLACE(Concatstring, ' ', '') AS Concatstringshort,
                          (SELECT     Country
                            FROM          dbo.Country_Tbl
                            WHERE      (CountryID = dbo.GenBoatData_Tbl.CountryID)) AS Country,
                          (SELECT     BoatType
                            FROM          dbo.BoatType_Tbl
                            WHERE      (BoatTypeID = dbo.GenBoatData_Tbl.BoatTypeID)) AS RM,
                          (SELECT     BoatRigGrp
                            FROM          dbo.BoatRigGrp_Tbl
                            WHERE      (BoatRigGrpID = dbo.GenBoatData_Tbl.BoatRigGrpID)) AS BoatRigGrp,
                          (SELECT     CASE WHEN genboatdata_Tbl.measured IS NULL THEN 0 ELSE genboatdata_Tbl.measured END AS Expr1) AS MM, LWL,
                          (SELECT     CASE WHEN Spl IS NOT NULL AND Stl IS NOT NULL THEN
                                                       (SELECT     CASE WHEN Stl > Spl THEN Stl ELSE Spl END) ELSE
                                                       (SELECT     CASE WHEN Spl IS NOT NULL AND Spl <> 0 THEN Spl ELSE Stl END) END AS Expr1) AS SPLGeneric,
                          (SELECT     BoatTypeMultiplier
                            FROM          dbo.BoatType_Tbl AS BoatType_Tbl_1
                            WHERE      (BoatTypeID = dbo.GenBoatData_Tbl.BoatTypeID)) AS BoatTypeMultiplier
FROM         dbo.GenBoatData_Tbl